<template>
	<view class="mainpadding2">
		<view class="flexcenter" v-if="!list.data.length">
			<view class="placeholderimage" style="margin-top: 300rpx;" ></view>
		</view>
		<view class="mainpadding radius ffffff margin_top" v-for="item in list.data" :key="item.id">
			<view class="">
				<view class="flexbetween">
					<view class="sanshier xiaohei fonweight">{{item.kcorder.name}}</view>
					<!-- 状态:1=待上课,2=已上课,3=旷课,4=已调课,5=已退费,6=请假审核中,7=已请假 -->
					<view class="xiaohui ershiba" v-if="item.status==1">待上课</view>
					<view class="xiaolan ershiba" v-if="item.status==2">已上课</view>
					<view class="xiaohong ershiba" v-if="item.status==3">旷课</view>
					<view class="xiaolv ershiba" v-if="item.status==4">已调课</view>
					<view class="xiaolv ershiba" v-if="item.status==5">已退费</view>
					<view class="xiaohuang ershiba" v-if="item.status==6">请假审核中</view>
					<view class="xiaolv ershiba" v-if="item.status==7">已请假</view>
				</view>
				<view class="ershiba xiaohui margin_top2 fonweight">{{item.sk_time_text}}  {{item.kckcb.start_time}}-{{item.kckcb.end_time}}</view>
				<view class="ershiba xiaohui margin_top2 fonweight">{{item.kc.address}}</view>
				<view class="ershiba xiaohui margin_top2 fonweight">{{item.kckcb.jlinfo.name}}</view>
			</view>
			<view class="flexright margin_top4">
				<view class="xiaolbtn margin_right2" v-if="item.sign_status==1 && item.status==1" @click="daka(item.id)">打卡</view>
				<view class="xiaolbtn margin_right2" @click="jumpurl('/pages_mypage/qingjia?id=',item.id)" v-if="item.qj_status==1 && item.status==1">请假</view>
				<view class="xiaolbtn margin_right2" v-if="item.status==1" @click="tiaoke(item.id,item.kc_kcb_id)">调课</view>
				<view class="xiaolbtn" v-if="item.kc.kc_attr!=2 && item.kc.kc_attr!=3" @click="tzgoum(item.kc_id)">续费</view>
				<view class="xiaohbtn" v-if="item.status!=1 && item.status!=6" @click="shanchu(item.id)">删除</view>
			</view>
		</view>
	</view>
</template>

<script>
	const httpRequest = require("@/common/httpRequest.js")

	export default {
		data() {
			return {
				page: 1,
				limit: 18,
				list: {
					data: []
				},
				listid:""
			}
		},
		onLoad(options) {
			this.listid = options.id
		},
		onShow() {
			
			this.init()
		},
		methods: {
			jumpurl(url,id){
				uni.navigateTo({
					url:url+id
				})
			},
			shanchu(id){
				httpRequest.request('/api/user/deleteUserKcKcb', 'GET', {
					id
				}, false, false, true).then(res => {
					httpRequest.toast(res.msg)
					if(res.code==1){
						this.init()
					}
				})
			},
			tzgoum(id) {
				uni.navigateTo({
					url: '/pages_homepage/kechengdingdanxq?id=' + id
				})
			},
			daka(id){
				httpRequest.request("/api/user/userKcKcbSign", 'GET', {
					id
				}, false, false, true).then(res => {
					httpRequest.toast(res.msg)
					if (res.code == 1) {
						this.init()
					}
				})
			},
			init(isPage, page) {
				let _this = this;
				let data = {
					page: page || 1,
					limit: _this.limit,
					ly:0,
					kc_order_id:this.listid
				}
				let url = '/api/user/userKcKcb'
				httpRequest.request(url, 'GET', data, false, false, true).then(res => {
					if (res.code == 1) {
						let resList = res.data;
						let dataList = _this.list;
						if (isPage == true) {
							_this.list.data = dataList.data.concat(resList.data);
						} else {
							this.list = res.data
							_this.list.data = resList.data;
						}
					}
				})
			},
			onReachBottom() {
				let _this = this;
				let list = _this.list;
				let page = _this.page;
				if (list.last_page <= page) {
					return false;
				}
				page++;
				_this.page = page;
				_this.init(true, page);
			},
			tiaoke(id,kc_kcb_id){
				uni.navigateTo({
					url: "/pages_mypage/tiaoke?id="+id+"&kc_kcb_id="+kc_kcb_id
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.xiaohbtn {
		width: 112rpx;
		height: 44rpx;
		background: #F76222;
		border-radius: 24rpx 24rpx 24rpx 24rpx;
		font-size: 24rpx;
		font-family: PingFang SC-Regular, PingFang SC;
		font-weight: 400;
		color: #FFFFFF;
		display: flex;
		align-items: center;
		justify-content: center;
	}

	.xiaolbtn {
		width: 112rpx;
		height: 44rpx;
		background: #1BA95B;
		border-radius: 24rpx 24rpx 24rpx 24rpx;
		font-size: 24rpx;
		font-family: PingFang SC-Regular, PingFang SC;
		font-weight: 400;
		color: #FFFFFF;
		display: flex;
		align-items: center;
		justify-content: center;
	}

	page {
		background: #F9F9F9;
	}
</style>